import React,{useState,useEffect,useLayoutEffect,useCallback,useMemo} from 'react';

export default function(){
  const [count,setCount]=useState(0)
  const [test,setTest]=useState('test-demo')
  useEffect( ()=>{
    console.log('useEffect')

    async function demo(){
      console.log('demo')
    }
    demo()
    // 执行异步
    fetch('/api/getLists')
  },[count])

  // 操作dom对象
  useLayoutEffect(()=>{
    console.log('useLayoutEffect')
  },[])
  const handleCount=()=>{
    setCount(count+1)
  }

  return(
    <div>
      <h1 onClick={handleCount}>count:{count}</h1>
    </div>
  )
}
